﻿// Copyright 2010 Maxime Serrano <lastchronicler@gmail.com>
// Copyright 2009, 2010 Matvei Stefarov <me@matvei.org>
using System;

namespace ForgeCraft
{
    public class CmdWhois : Command
    {
        public override string name { get { return "whois"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "player"; } }
        public override bool consoleUsable { get { return false; } }
        public override Permission defaultRank { get { return Permission.Guest; } }
        public CmdWhois() { }

        public override void Use(Player p, string message)
        {
            if (message == null)
            {
                //TODO: Show help
                return;
            }

            Player target = Server.FindPlayerByNick(message);
            if (target != null)
            {
                if (target.nick != target.name)
                {
                    p.Message("Player named " + target.name + " is using a nickname \"" + target.nick + "\"");
                }
                else
                {
                    p.Message("Player named " + target.name + " is not using any nickname.");
                }
            }
            else
            {
                p.NoPlayerMessage(message);
            }
        }
        public override void Help(Player p)
        {
            p.Message(Color.Aqua + "/whois " + Color.Help + "- Shows whether a player uses a real name or nickname. Note: case-sensitive.");           
        }
    }
}